package com.neo.common.base;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.HashMap;

/**
 * 后台自定义响应结构
 */
public class BaseResult implements Serializable {

    // 响应业务状态


    @ApiModelProperty("状态码")
    private Integer status;

    // 响应消息
    @ApiModelProperty("信息")
    private String msg;

    // 响应中的数据
    @ApiModelProperty("数据")
    private Object data;

    public BaseResult() {
    }

    public BaseResult(Object data) {
        this.status = 200;
        this.msg = "success";
        this.data = data;
    }

    public static BaseResult success(Object data) {
        return new BaseResult(data);
    }

    public static BaseResult success() {
        return new BaseResult(new HashMap<>());
    }

    public static BaseResult error(Integer status, String msg, Object data) {
        return new BaseResult(status, msg, data);
    }

    public static BaseResult error(Integer status, String msg) {
        return new BaseResult(status, msg, new HashMap<>());
    }

    public BaseResult(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
